// initial state
import { StoreOptions } from "vuex";
import { JudgeControllerService } from "../../generated/services/JudgeControllerService";

export default {
  namespaced: true,
  state: () => ({
    judgeInfo: {},
    judgeResult: {},
    judgeStatus: {},
  }),
  actions: {
    async initJudgeInfo({ commit, state }, payload) {
      // 从远程请求获取登录信息
      const res = await JudgeControllerService.getJudgeInfoUsingGet();
      if (res.code === 0) {
        commit("updateJudgeInfo", res.data);
      }
      console.log("initJudgeInfo", res);
    },
  },
  mutations: {
    updateJudgeInfo(state, payload) {
      state.judgeInfo = payload;
      state.judgeResult = payload.judgeResult;
      state.judgeStatus = payload.judgeStatus;
    },
  },
} as StoreOptions<any>;
